home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr47
/
batime.zip
/
TIMEOUT.DOC
< prev
Wrap
Text File
|
1993-04-21
|
4KB
|
98 lines
TIMEOUT.COM Released to public domain.
TIMEOUT.COM docs.
Timeout is a decision loop for use in DOS batch files.
When started (the command takes no arguments or parameters), the
program looks for a Y or y entry. If found before the program
times out, timeout returns an ERRORLEVEL exit code of 10. If any
other keystroke is detected or if the program times out, timeout
returns an ERRORLEVEL exit code of 20.
***************************************************************
A typical use of timeout.com would be in an autoexec.bat file
as follows:
echo Don't launch Windows 3.1? (y/n)?
timeout
rem Timeout returns exit code 20 if Y/y pressed, exit code 10
rem for any other keypress or if it times out.
if errorlevel 10 if not errorlevel 11 goto winit
if errorlevel 20 if not errorlevel 21 goto stopit
:winit
win
:stopit
**************************************************************
The timeout loop is set by a value in the first instruction of the
program and can be changed using DEBUG, as follows (in the
following example, capitalization does not matter; <ret> means hit
the enter key; xxxx and nnnn are explained after the example):
DEBUG RESPONDS YOU TYPE
debug timeout.com <ret>
- a 0100 <ret>
xxxx:0100 mov cx,nnnn <ret>
xxxx:0103 <ret>
- w <ret>
- q <ret>
After the last <ret>, DEBUG will return you to the DOS prompt. The
value of xxxx is unimportant and may be ignored. The value of nnnn
is the timeout delay expressed in hexidecimal and is just an
arbitrary number. The larger the value of nnnn, the longer the
wait before timeout. The number does not correspond directly to
seconds or anything because the speed with which the program
executes is dependent on the speed of the machine it's run on.
With my 386SX 20, the default value of 4000 takes about 10 seconds
to timeout.
*************************************************************
F.Y.I., the assembly code for timeout.com follows:
; timeout loop
MOV CX,1388 ; load loop value into cx for use by LOOP
MOV AH,0B ; [103] use DOS to see if key pressed
INT 21 ; do last step
CMP AL,FF ; last step puts ff into al if key pressed
JZ 011F ; if true (0), jump out of loop
LOOP 0103 ; loop, exits if cx down to 0
; exit code 10 (timeout or non-y/Y)
MOV DL,0D ; [010D] stick carriage return into dl
MOV AH,02 ; print that carriage return to screen
INT 21
MOV DL,0A ; repeat last 3 steps except with linefeed
MOV AH,02
INT 21
MOV AL,0A ; stick decimal 10 into al register
MOV AH,4C ; exit and take al value as exit code
INT 21
; process keypress
MOV AH,01 ; [11F] get key that was pressed, put in al
INT 21
CMP AL,00 ; if al is 00, then extended key was pressed
JZ 010D ; if al=00 go to exit code 10 exit
CMP AL,59 ; is al=Y?
JZ 0131 ; if so go to exit code 20 exit
CMP AL,79 ; is al=y
JZ 0131 ; if so go to exit code 20 exit
JMP 010D ; if not Y or y go to exit code 10 exit
; exit code 20 exit (Y/y pressed)
MOV DL,0D ; [0131] stick carriage return into dl
MOV AH,02 ; print that carriage return to screen
INT 21
MOV DL,0A ; repeat last 3 steps except with linefeed
MOV AH,02
INT 21
MOV AL,14 ; stick decimal 20 into al register
MOV AH,4C ; exit and take al value as exit code
INT 21